<template>
  <div class="mod-hotSearcch">
    <div class="title">是否接入美团</div>
    <div class="notice">
      提示：如果选择接入美团，订单将优先美团配送
    </div>
    <div class="setting-box">
      <div class="setting-item">
        <span class="item-tit">设置：</span>
        <el-switch
          v-model="value"
          active-color="#13ce66"
          :width='80'
          :active-value="1"
          :inactive-value="0">
        </el-switch>  
      </div>
      <div class="setting-btn setting-=item">
        <el-button type="primary" @click="submit">保存</el-button>
      </div>
    </div>

  </div>
</template>

<script>
export default {
  data () {
    return {
      value: 0,
    }
  },
  methods: {
    getMyInfo(){
      this.$http({
        url:this.$http.adornUrl("/shop/shopDetail/getShopDetailInformation"),
        method: 'get',
      }).then(({data}) =>{
        this.value  = data.meituanDistributionFlag
      }) 
    },

    submit(){
      this.$http({
        url: this.$http.adornUrl('/shop/shopDetail/updateInformation'),
        method: 'put',
        params: this.$http.adornParams({
          meituanDistributionFlag: this.value
        })
      }).then((res) =>{
        this.$message({
          message: '保存成功',
          type: 'success',
          duration: 1500
        })
      })
    },
  },

  created(){
    this.getMyInfo()
  }
}
</script>

<style scoped>
.title{
  margin-left: 30px;
  color: #444;
  font-size: 24px;
}
.title::before{
  content: '';
  border-right: 3px solid #02A1E9;
  margin-right: 5px;
}
.notice{
  margin: 15px 0 0 35px;
  color: #888;
}
.setting-box{
  width: 600px;
  border: 1px solid #EBEEF5;
  padding: 30px 180px;
  margin: 30px auto;
}
.setting-item{
  margin: 10px 50px;
}
.setting-box .setting-item .item-tit{
  width: 60px;
}
.setting-btn{
  margin: 30px 0 0 72px;
}
.setting-item >>>.el-switch__core{
    height: 40px;
    border-radius: 40px;
}
.setting-item >>>.el-switch__core:after{
    height: 37px;
    width: 37px;
    top: 0px;
    left: 1px;
}
.setting-item >>>.el-switch.is-checked .el-switch__core:after{
  margin-left: 40px;
}
.el-button{
  width: 100px;
}

</style>